\documentclass[11pt]{article}

% Engine-specific settings
% pdftex:
\ifcsname pdfmatch\endcsname
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
\fi
% xetex:
\ifcsname XeTeXinterchartoks\endcsname
    \usepackage{fontspec}
    \defaultfontfeatures{Ligatures=TeX}
\fi
% luatex:
\ifcsname directlua\endcsname
    \usepackage{fontspec}
\fi
% End engine-specific settings

\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage[keeptemps=all, makestderr, usefamily={Rcon}]{pythontex}


\begin{document}


\section*{R Console}


\subsection*{Basics}

Console math and printing.

\begin{Rconsole}
1+4
print("Some text ...")
\end{Rconsole}

Test \pygment{r}{cat()} without a trailing newline \verb|\n|.  This should produce output followed immediately on the same line by the prompt and the next command.
\begin{Rconsole}
cat("Some", "text", "...")
cat("And", "some", "more", "...")
\end{Rconsole}

After a final \pygment{r}{cat()} without a trailing newline \verb|\n|, the next environment should start normally, with the prompt at the beginning of the line.

\begin{Rconsole}
write("stdout", stdout())
write("stderr", stderr())
\end{Rconsole}


\subsection*{Continuity between environments}

Set a variable.
\begin{Rconsole}
x <- 2^12
\end{Rconsole}

Retrieve variable value.
\begin{Rconsole}
x
\end{Rconsole}


\subsection*{Continue after errors}

\begin{Rconsole}
1+"a"
3*6
\end{Rconsole}



\end{document}

